<style lang="less" scoped>


</style>

<template>
  <div class>
    <div class="tabs">
      <!-- <cube-tab-bar v-model="selectedIndex" :data="tabs" @change="changeHandler"></cube-tab-bar> -->
      <van-tabbar v-model="selectedIndex" @change="changeHandler">
        <van-tabbar-item v-for="(x,i) of tabs" :key="i" :icon="x.icon">{{x.label}}</van-tabbar-item>
      </van-tabbar>
    </div>
    <transition name="fade">
      <!-- <keep-alive> -->
      <router-view class="router-view"></router-view>
      <!-- </keep-alive> -->
    </transition>
  </div>
</template>
<script>
import { mapState, mapMutations, mapActions } from "vuex";

export default {
  data() {
    return {
      toast: null,
      orders: [],
      showOrders: [],
      selectedIndex: 0,
      tabs: [
        {
          label: "首页",
          value: 0,
          key: "index",
          icon: "home-o",
          class: "tab"
        },
        {
          label: "统计",
          value: 1,
          key: "cart",
          icon: "cart-o",
          class: "tab"
        },
        {
          label: "查询",
          value: 2,
          key: "search",
          icon: "gem-o",
          class: "tab"
        },
        {
          label: "我的",
          value: 3,
          key: "my",
          icon: "friends-o"
        }
      ],
      compid: 0,
      paperid: ""
    };
  },
  computed: {
    ...mapState(["indexNum", "dduser", "comps", "remote"])
  },
  created() {
   
  },
  mounted() {
    this.selectedIndex = this.indexNum;
  },
  methods: {
    changeHandler(value) {
      this.updateIndexNum(value);
      let tab = this.tabs[value];
      console.log("value", value, tab);
      this.$router.push({ name: this.tabs[value].key });
    },
    ...mapMutations(["updateIndexNum", "updateDduser", "updateJsconfig"]),
    ...mapActions([
      "fetchCorpid",
      "fetchUserinfo",
      "fetchOrders",
      "fetchComps",
      "fetchJsconfig",
      "updateRole"
    ])
  },
  components: {
    
  }
};
</script>
